import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

class MyJPanel
extends JPanel
{
  private static final long serialVersionUID = 1L;
  private BufferedImage bi = null;
  private int x = 0;
  private int y = 0;
  private int w = 600;
  private int h = 600;

  /*****************************************************************\
   * Construction
  \*****************************************************************/
  MyJPanel(String name, int newx, int newy)
  {
    System.out.println("MyJPanel()");
    try
    {
      bi = ImageIO.read(getClass().getResourceAsStream(name));
    }
    catch (IOException ioe)
    {
      System.err.println("MyJPanel(): "+ioe.getMessage());
    }
    x = newx;
    y = newy;
    setBounds(x, y, w, h);
  }

  /*****************************************************************\
   * Painting - use paintComponent() and don't use paint()
  \*****************************************************************/
  @Override
  protected void paintComponent(Graphics g)
  {
    //System.out.println("MyJPanel.paintComponent("+g+")");
    g.drawImage(bi, 0, 0, w-1, h-1, null);
  }
}